<template>
	<view>
		<uni-search-bar placeholder="自定义背景色" bgColor="#EEEEEE" @confirm="onSearch" />
		<uni-card :is-shadow="true">
			<uni-list :border="false">
				<uni-list-item @click="onLink(item.id)" v-for="item in dataInfo" :key="item.id" :title="item.title" showArrow clickable />
			</uni-list>
		</uni-card>
		
		<view class="fixed-bottom">
			<view><button type="primary" @click="onSelect">选择交底类别</button></view>
		</view>
		<uni-popup ref="popup" type="bottom" background-color="#fff">
			<div class="text-right p5"><uni-icons @click="onClose" type="close" size="20"></uni-icons></div>
			<uni-card :is-shadow="true" style="height: 600px;">
				<uni-list :border="false">
					<uni-list-item @click="onSelectType(item.id)" v-for="item in typeDate" :key="item.id" :title="item.title" clickable />
				</uni-list>
			</uni-card>
		</uni-popup>
	</view>
</template>

<script>
import request from '../../api/request'

	export default {
		data() {
			return {
				form:{type_id:0,project_id:0},
				project:{},
				dataInfo:[],
				typeDate:[]
			}
		},
		onLoad() {
			this.project = uni.getStorageSync('project')
			this.form.project_id = this.project.id
			this.onGetData()
		},
		methods: {
			onSelect(){
				this.$refs.popup.open('bottom')
			},
			onSelectType(id){
				this.form.type_id = id
				this.onGetData();
				this.$refs.popup.close()
			},
			onClose(){
				this.$refs.popup.close()
			},
			onGetData(){
				let _this = this
				request('disclosure','POST',this.form).then(res => {
					if(res.code != 200){
						uni.showToast({title: res.msg,icon: 'error',duration: 2000})
						return;
					}
					_this.dataInfo = res.data
					_this.typeDate = res.type
				}).catch(err => {
					console.log(err)
				})
			},
			onChange(){
				
			},
			onLink(id){
				uni.navigateTo({
					url: '/pages/disclosure/info/info?id='+id
				});
			},
			onSearch(){
				
			}
		}
	}
</script>

<style>

</style>
